Skip to content

[FEATURE] Add public API to set / get vertex positions of visual rigid geometries.#2776

Merged
duburcqa merged 8 commits into
Genesis-Embodied-AI:mainfrom
duburcqa:vverts-consolidation
May 13, 2026
Merged

[FEATURE] Add public API to set / get vertex positions of visual rigid geometries.#2776
duburcqa merged 8 commits into
Genesis-Embodied-AI:mainfrom
duburcqa:vverts-consolidation

Conversation

@duburcqa
Copy link
Copy Markdown
Collaborator

Summary

Adds vverts_state to KinematicSolver as the single engine-side ground truth for per-frame world-space visual vertex positions. Surfaces set_vverts / get_vverts at solver, entity, and vgeom levels. Rasterizer picks up user overrides via a lazy migration to per-env vertex-buffer rendering; collision/sdf rendering is unchanged.

This is the renderer half. PR #2769 (visual-mesh raycasting) rebases on top of this — its kernel_copy_custom_vverts and parallel _custom_vverts buffer go away because vverts_state is now the engine-level buffer everyone reads.

Supersedes the closed #2768 by relocating the buffer from KinematicEntity to the solver.

Design

  • vverts_state.pos: gs.qd_vec3, (n_vverts_, B) — populated by kernel_update_all_vverts (vgeom-pose × init_pos) in KinematicSolver.update_vgeoms.
  • vverts_info.is_custom: gs.qd_int — flips to 1 for entries written by set_vverts. FK skips them so user data survives step().
  • KinematicOptions.batch_vverts_info: bool = False (mirrors batch_links_info / batch_dofs_info / batch_joints_info). When True, the whole vverts_info struct gains a B dimension; without it, partial envs_idx on set_vverts raises.
  • set_vverts(verts, envs_idx=None) / get_vverts(envs_idx=None) at KinematicSolver, KinematicEntity, Vgeom. vverts=None clears. Plane entities are refused.
  • Rasterizer: non-custom entities keep the existing instancing path. Entities with any custom vvert migrate to per-env pyrender nodes that re-upload from vverts_state.pos each frame. Clear migrates back; the restored render is byte-identical to baseline.
  • Zero-copy on set_vverts when supported; warns once per build on non-zero-copy backends and uses a fallback kernel.

Test plan

  • tests/test_render.py::test_set_vverts[False-RASTERIZER] and [True-RASTERIZER] cover the API + render path end-to-end (round-trip, broadcast forms, get-returns-copy, vgeom-level write, Plane refusal, migration back, partial-envs error for unbatched, mixed user/FK envs for batched).
  • Reviewers verify the vverts_info batching change doesn't break existing consumers (only one in genesis/vis/batch_renderer.py; adjusted to take env-0 slice when batched).

Relationship to other PRs

@duburcqa duburcqa requested a review from YilingQiao as a code owner May 12, 2026 20:09
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0c6587a54c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread genesis/vis/rasterizer_context.py Outdated
@duburcqa duburcqa force-pushed the vverts-consolidation branch 4 times, most recently from 801530e to 263f344 Compare May 13, 2026 14:58
duburcqa added 6 commits May 13, 2026 19:36
Allocating vverts_state.pos at (n_vverts, B) for every kinematic entity scales
linearly with mesh size and env count, which is unacceptable for scenes with
large kinematic meshes. Introduce a per-entity opt-in flag (custom_vverts on
Mesh / Primitive / URDF / MJCF / USD via CustomVvertsMixin) and resize
vverts_state / vverts_info / vfaces_info to n_custom_vverts_ / n_custom_vfaces_
- only entities that explicitly opt in get persistent storage. set_vverts /
get_vverts now raise on non-opted entities.

Also fix a non-contiguous tensor crash in the kernel fallback path by calling
.contiguous() on the broadcast_tensor result.
@duburcqa duburcqa force-pushed the vverts-consolidation branch 3 times, most recently from 3436e7e to 90d2422 Compare May 13, 2026 19:47
The migration-forward branch in update_rigid queued an update_buffer call against
get_buffer_id(node, "pos") for a freshly-added pyrender node, but pyrender allocates the
GL buffers lazily during the upcoming render pass. The buffer id resolves to -1 at queue
time, so the first frame after a set_vverts-triggered migration was silently dropped and
rendered the initial sphere positions. Seed primitive.positions on the new node so the
first GL upload uses the current vverts_state directly.

Add tests/test_render.py::test_set_vverts_sphere_to_box covering the morph: a grid-
subdivided cube (602 verts, vertices at every cube corner) is spherified for the
deformable's initial mesh; top-down segmentation masks of the deformable before, after
set_vverts(cube_verts), and after set_vverts(None) are compared against gs.morphs.Sphere
and gs.morphs.Box references. Box comparison is byte-equal (corner vertex alignment),
sphere comparison allows 0.5% boundary-pixel jitter (different tessellations).
@github-actions
Copy link
Copy Markdown

🔴 Benchmark Regression Detected ➡️ Report

@duburcqa duburcqa force-pushed the vverts-consolidation branch from 90d2422 to 459803c Compare May 13, 2026 21:19
@duburcqa duburcqa force-pushed the vverts-consolidation branch from 459803c to f231ada Compare May 13, 2026 21:21
@duburcqa duburcqa changed the title [FEATURE] Engine-owned visual vertex buffer (set_vverts / get_vverts API) [FEATURE] Add public API to set / get vertex positions of visual rigid geometries. May 13, 2026
@duburcqa duburcqa merged commit a78d023 into Genesis-Embodied-AI:main May 13, 2026
20 checks passed
@github-actions
Copy link
Copy Markdown

🔴 Benchmark Regression Detected ➡️ Report

@duburcqa duburcqa deleted the vverts-consolidation branch May 28, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant